package sagroup.dracots.policy;

public class UpdatePolicy {

	final byte updatePolicy;

	// update policy constants.
	/**
	 * A replica can acquire update from any other hosts.
	 */
	static final byte ANY = 0x10;
	/**
	 * A replica can only acquire update from the host holding the master.
	 */
	static final byte MASTER = 0x20;

	public UpdatePolicy(byte updatePolicy) {
		assert (updatePolicy == MASTER) || (updatePolicy == ANY);
		this.updatePolicy = updatePolicy;
	}

	public byte getUpdatePolicy() {
		return updatePolicy;
	}

	public String toString() {
		switch (updatePolicy) {
		case ANY:
			return "ANY";
		case MASTER:
			return "MASTER";
		default:
			return "UNKNOWN";
		}
	}
}
